<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <DefineConstants>$(DefineConstants);RESOURCES_EXTENSIONS</DefineConstants>
    <EnableAOTAnalyzer>false</EnableAOTAnalyzer>
    <IncludeInternalObsoleteAttribute>true</IncludeInternalObsoleteAttribute>
    <UseCompilerGeneratedDocXmlFile>false</UseCompilerGeneratedDocXmlFile>
    <IsPackable>true</IsPackable>
    <SuggestedBindingRedirectsPackageFile>$(BaseIntermediateOutputPath)SuggestedBindingRedirects.targets</SuggestedBindingRedirectsPackageFile>
    <BeforePack>$(BeforePack);GeneratePackageTargetsFile</BeforePack>
    <PackageDescription>Provides classes which read and write resources in a format that supports non-primitive objects.

Commonly Used Types:
System.Resources.Extensions.DeserializingResourceReader
System.Resources.Extensions.PreserializedResourceWriter</PackageDescription>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="$(CommonPath)System\Obsoletions.cs"
             Link="Common\System\Obsoletions.cs" />
    <Compile Include="$(CommonPath)System\Resources\ResourceWriter.cs"
             Link="System\Resources\Extensions\ResourceWriter.cs" />
    <Compile Include="$(CoreLibSharedDir)System\IO\PinnedBufferMemoryStream.cs"
             Link="System\IO\PinnedBufferMemoryStream.cs" />
    <Compile Include="$(CoreLibSharedDir)System\Resources\FastResourceComparer.cs"
             Link="System\Resources\FastResourceComparer.cs" />
    <Compile Include="$(CoreLibSharedDir)System\Resources\ResourceReader.cs"
             Link="System\Resources\Extensions\ResourceReader.cs" />
    <Compile Include="$(CoreLibSharedDir)System\Resources\ResourceTypeCode.cs"
             Link="System\Resources\ResourceTypeCode.cs" />
    <Compile Include="$(CoreLibSharedDir)System\Resources\RuntimeResourceSet.cs"
             Link="System\Resources\Extensions\RuntimeResourceSet.cs" />
    <Compile Include="BinaryReaderExtensions.cs" />
    <Compile Include="BinaryWriterExtensions.cs" />
    <Compile Include="System\Resources\Extensions\DeserializingResourceReader.cs" />
    <Compile Include="System\Resources\Extensions\PreserializedResourceWriter.cs" />
    <Compile Include="System\Resources\Extensions\SerializationFormat.cs" />
    <Compile Include="System\Resources\Extensions\TypeNameComparer.cs" />
    <Compile Include="$(CoreLibSharedDir)System\Numerics\Hashing\HashHelpers.cs"
             Link="System\Numerics\Hashing\HashHelpers.cs" />
  </ItemGroup>

  <ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
    <Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\RequiresUnreferencedCodeAttribute.cs" 
             Link="System\Diagnostics\CodeAnalysis\RequiresUnreferencedCodeAttribute.cs" />
    <Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\UnconditionalSuppressMessageAttribute.cs"
             Link="System\Diagnostics\CodeAnalysis\UnconditionalSuppressMessageAttribute.cs" />
  </ItemGroup>

  <ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
    <PackageReference Include="System.Memory" Version="$(SystemMemoryVersion)" />
  </ItemGroup>

  <Target Name="GeneratePackageTargetsFile" 
          Inputs="$(MSBuildAllProjects)"
          Outputs="$(SuggestedBindingRedirectsPackageFile)"
          Condition="'$(NetFrameworkMinimum)' != ''">
    <PropertyGroup>
      <SuggestedBindingRedirectsPackageFileContent><![CDATA[<Project>
  <!-- ResolveAssemblyReferences will never see the assembly reference embedded in the resources type,
       force a binding redirect ourselves so that we'll always unify to the System.Resources.Extensions
       version provided by this package -->
  <ItemGroup>
    <SuggestedBindingRedirects Include="$(AssemblyName), Culture=neutral, PublicKeyToken=$(PublicKeyToken)" MaxVersion="$(AssemblyVersion)" />
  </ItemGroup>
</Project>
]]></SuggestedBindingRedirectsPackageFileContent>
    </PropertyGroup>

    <WriteLinesToFile File="$(SuggestedBindingRedirectsPackageFile)"
                      Lines="$(SuggestedBindingRedirectsPackageFileContent)"
                      Overwrite="true" />

    <ItemGroup>
      <Content Include="$(SuggestedBindingRedirectsPackageFile)"
               PackagePath="buildTransitive\$(NetFrameworkMinimum)\$(PackageId).targets" />
    </ItemGroup>
  </Target>

</Project>
